﻿<?php
session_start();
$page = 'inscription';
include('include/header.php');
//include('include/connexion_bdd.php');
$complet = 0;
?>
<body>
    <div id="content">
        <div id="countdown"></div>
        <p id="note"></p>

        <img src="assets/image/trait_horizontal.png" style="margin-left:auto; margin-right:auto;width:600px; display:block;">

        <div id="content2">
            <?php
            $req = competition();
            ?>
            <div class="placesRestantesTitre">Places Restantes : </div>
            <div class="placeRestante">
                <?php
                while ($ligne = $req->fetch()) {
                    $complet += $ligne['nbPlaceDispo'];
                    ?><div class='nomCompetition'><?php echo $ligne['nomCompetition'] . " : " ?></div><div class='nbPlace'><?php echo $ligne['nbPlaceDispo']; ?></div><?php
            }
                ?>
            </div>

            <?php
            if ($complet > 0) {

                if (isset($_SESSION['login'])) {
                    $req = findParticipantbyEmail($_SESSION['login']);
                    $ligne = $req->fetch();
                    if (isset($ligne['idParticipant'])) {
                        $reqInscrit = findInscrireById($ligne['idParticipant']);
                        $inscrire = $reqInscrit->fetch();

                        if (isset($inscrire['fkIdParticipant'])) {
                            ?>
                            <div class="informationFreeride">
                                <img class="vertical_image" src="assets/image/suivant.png"> <span class="informationInscription"><button class="boutonInscriptionValide">Vous êtes déjà inscrits pour le Marchaux Classic Freeride 2014 !</button></span>
                            </div></br></br>
                            <?php
                        } else {
                            ?>
                            <a href="marchaux.php"><div class="informationFreeride">
                                    <img class="vertical_image" src="assets/image/suivant.png"> <span class="informationInscription">  <button class="boutonInscription">Je m'inscris au Freeride !</button></span>
                                </div></a></br></br>
                            <?php
                        }
                    } else {
                        ?>
                        <a href="marchauxInscriptionForm.php"><div class="informationFreeride">
                                <img class="vertical_image" src="assets/image/suivant.png"> <span class="informationInscription">  <button class="boutonInscription">Je m'inscris au Freeride !</button></span>
                            </div></a></br></br>
                        <?php
                    }
                } else {
                    ?>
                    <div class="informationFreeride">
                        <img class="vertical_image" src="assets/image/attention.png" width="50px"> <span class="informationImportante"> <button class="boutonProbleme">Vous devez être connecté sur le site pour vous inscrire au freeride !</button></span>
                    </div></br></br>
                    <?php
                }
            } else {
                ?>  
                <div class="informationFreeride">
                    <img class="vertical_image" src="assets/image/attention.png" width="50px"> <span class="informationImportante"> Plus de place disponibles !</span>
                </div></br></br>
            <?php } ?>        

            <a href="marchaux_information.php"><div class="informationFreeride">
                    <img class="vertical_image" src="assets/image/suivant.png"/> <span class="informationImportante"> Informations concernant le freeride</span>
                </div></a></br></br>
            <a href="marchaux_liste_inscrit.php"><div class="informationFreeride">
                    <img class="vertical_image" src="assets/image/suivant.png"> <span class="informationImportante"> Voir la liste des inscrits</span>
                </div></a></br></br>
        </div>
    </div>
</body>
<?php
include('include/footer.php');
?>